```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java管道流通信详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
        }
        .hero {
            background: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            overflow-x: auto;
        }
        .code-keyword { color: #569cd6; }
        .code-type { color: #4ec9b0; }
        .code-string { color: #ce9178; }
        .code-comment { color: #6a9955; }
        .code-method { color: #dcdcaa; }
        .card-hover {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .mermaid {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">Java管道流通信详解</h1>
                    <p class="text-xl mb-8 opacity-90">线程间高效通信的优雅解决方案</p>
                    <div class="flex space-x-4">
                        <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">多线程</span>
                        <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">IO流</span>
                        <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">进程通信</span>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid">
                        graph LR
                            A[发送线程] -- 管道输出流 --> B((管道))
                            B -- 管道输入流 --> C[接收线程]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl py-12 px-4">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-xl p-8 shadow-lg card-hover">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-4 font-serif">管道流概述</h2>
                <p class="text-lg mb-6 text-gray-700">管道流（Piped Stream）是Java中用于线程间通信的一种机制，它允许一个线程产生的数据直接流向另一个线程，实现高效的数据传输。</p>
                
                <div class="grid md:grid-cols-2 gap-6 mb-8">
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <div class="flex items-center mb-3">
                            <i class="fas fa-arrow-circle-right text-blue-500 text-2xl mr-3"></i>
                            <h3 class="text-xl font-semibold text-blue-800">管道输出流</h3>
                        </div>
                        <p class="text-gray-700">PipedOutputStream，负责向管道写入数据，是线程间通信的生产者端。</p>
                    </div>
                    <div class="bg-green-50 p-6 rounded-lg">
                        <div class="flex items-center mb-3">
                            <i class="fas fa-arrow-circle-left text-green-500 text-2xl mr-3"></i>
                            <h3 class="text-xl font-semibold text-green-800">管道输入流</h3>
                        </div>
                        <p class="text-gray-700">PipedInputStream，负责从管道读取数据，是线程间通信的消费者端。</p>
                    </div>
                </div>
                
                <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-exclamation-circle text-yellow-500 text-xl"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-yellow-700">关键点：必须将输出流连接到输入流上才能正常工作，可以使用connect()方法建立连接。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Code Example -->
        <section class="mb-16">
            <div class="bg-white rounded-xl p-8 shadow-lg card-hover">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-4 font-serif">代码实现</h2>
                <div class="mb-8">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">1. 创建发送线程</h3>
                    <div class="code-block p-6 mb-6">
                        <pre><code>
<span class="code-keyword">class</span> <span class="code-type">Send</span> <span class="code-keyword">implements</span> <span class="code-type">Runnable</span> {     <span class="code-comment">// 发送</span>

     <span class="code-keyword">private</span> <span class="code-type">PipedOutputStream</span> pos = <span class="code-keyword">null</span>; <span class="code-comment">// 定义一个管道输出流</span>

     <span class="code-keyword">public</span> <span class="code-type">Send</span>() {
            <span class="code-keyword">this</span>. pos = <span class="code-keyword">new</span> <span class="code-type">PipedOutputStream</span>();
     }

     <span class="code-keyword">public</span> <span class="code-type">void</span> <span class="code-method">run</span>() {
           <span class="code-type">String</span> str = <span class="code-string">"hello World"</span>; <span class="code-comment">// 定义输出信息</span>
            <span class="code-keyword">try</span> {
                 pos.write(str.getBytes()); <span class="code-comment">// 输出一个字节数组</span>
           } <span class="code-keyword">catch</span> (<span class="code-type">IOException</span> e) {
                e.printStackTrace();
           } <span class="code-keyword">finally</span> {
                 <span class="code-keyword">try</span> {
                      pos.close(); <span class="code-comment">// 关流</span>
                } <span class="code-keyword">catch</span> (<span class="code-type">IOException</span> e) {
                     e.printStackTrace();
                }
           }
     }

     <span class="code-keyword">public</span> <span class="code-type">PipedOutputStream</span> <span class="code-method">getPos</span>() { <span class="code-comment">// 通过线程类得到输出流</span>
            <span class="code-keyword">return</span> pos;
     }
}
                        </code></pre>
                    </div>
                </div>

                <div class="mb-8">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">2. 创建接收线程</h3>
                    <div class="code-block p-6 mb-6">
                        <pre><code>
<span class="code-keyword">class</span> <span class="code-type">Recelive</span> <span class="code-keyword">implements</span> <span class="code-type">Runnable</span>{        <span class="code-comment">// 收到</span>

     <span class="code-keyword">private</span> <span class="code-type">PipedInputStream</span> pis = <span class="code-keyword">null</span>; 
     
     <span class="code-keyword">public</span> <span class="code-type">Recelive</span>(){
            pis = <span class="code-keyword">new</span> <span class="code-type">PipedInputStream</span>();    <span class="code-comment">// 实例化输入流</span>
     }
     
     <span class="code-keyword">public</span> <span class="code-type">void</span> <span class="code-method">run</span>() {
            <span class="code-type">byte</span>[] by = <span class="code-keyword">new</span> <span class="code-type">byte</span>[1024];
            <span class="code-type">int</span> read = 0;
            <span class="code-keyword">try</span> {
                read = pis.read(by); <span class="code-comment">// 读到一个数组中</span>
           } <span class="code-keyword">catch</span> (<span class="code-type">IOException</span> e) {
                e.printStackTrace();
           } <span class="code-keyword">finally</span>{
                 <span class="code-keyword">try</span> {
                      pis.close();
                } <span class="code-keyword">catch</span> (<span class="code-type">IOException</span> e) {
                     e.printStackTrace();
                }
           }
           <span class="code-type">System</span>. out.println( <span class="code-string">"读出的内容："</span> +<span class="code-keyword">new</span> <span class="code-type">String</span>(by,0,read));  <span class="code-comment">// 转成字符串</span>
     }
     
     <span class="code-keyword">public</span> <span class="code-type">PipedInputStream</span> <span class="code-method">getPis</span>(){     <span class="code-comment">// 得到输入流</span>
            <span class="code-keyword">return</span> pis;
     }
}
                        </code></pre>
                    </div>
                </div>

                <div class="mb-8">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">3. 主程序与连接</h3>
                    <div class="code-block p-6 mb-6">
                        <pre><code>
<span class="code-keyword">public</span> <span class="code-keyword">class</span> <span class="code-type">Tese01</span> {
     <span class="code-keyword">public</span> <span class="code-keyword">static</span> <span class="code-type">void</span> <span class="code-method">main</span>(<span class="code-type">String</span>[] args) <span class="code-keyword">throws</span> <span class="code-type">Exception</span> {
           
           <span class="code-type">Send</span> send = <span class="code-keyword">new</span> <span class="code-type">Send</span>();
           <span class="code-type">Recelive</span> recaive = <span class="code-keyword">new</span> <span class="code-type">Recelive</span>();
           
           send.<span class="code-method">getPos</span>().connect(recaive.getPis()); <span class="code-comment">// 连接管道</span>
           
            <span class="code-keyword">new</span> <span class="code-type">Thread</span>(send).start();
            <span class="code-keyword">new</span> <span class="code-type">Thread</span>(recaive).start();
     }
}
                        </code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Explanation -->
        <section class="mb-16">
            <div class="bg-white rounded-xl p-8 shadow-lg card-hover">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-4 font-serif">关键点解析</h2>
                
                <div class="mb-8">
                    <div class="flex items-start mb-6">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-link text-blue-600 text-xl"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2 text-gray-700">连接机制</h3>
                            <p class="text-gray-700">使用PipedOutputStream的connect()方法将输出流连接到输入流上，这是管道流能够工作的前提条件。连接后，数据可以从输出流直接流向输入流。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start mb-6">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-exchange-alt text-purple-600 text-xl"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2 text-gray-700">线程安全</h3>
                            <p class="text-gray-700">管道流内部实现了线程同步机制，确保多线程环境下的数据传输安全。发送线程和接收线程可以同时运行，互不干扰。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="bg-green-100 p-3 rounded-full mr-4">
                            <i class="fas fa-tint text-green-600 text-xl"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2 text-gray-700">数据流特性</h3>
                            <p class="text-gray-700">管道流遵循先进先出(FIFO)原则，数据按照写入的顺序依次读取。读取操作会阻塞直到有数据可用，写入操作也可能阻塞直到接收端读取数据。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-gray-100 p-6 rounded-lg">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">工作流程示意图</h3>
                    <div class="mermaid">
                        sequenceDiagram
                            participant S as 发送线程
                            participant P as 管道
                            participant R as 接收线程
                            S->>P: connect()
                            S->>P: write(data)
                            P->>R: data
                            R->>R: process(data)
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-10">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索编程之美，分享技术精髓</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-external-link-alt mr-2"></i>访问技术小馆
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            fontFamily: 'Noto Sans SC, sans-serif'
        });
    </script>
</body>
</html>
```